Skip to content

[Enhancement] Allow reverting asset change - #437

Merged
ledsoft merged 27 commits into
kbss-cvut:developmentfrom
lukaskabc:lukaskabc/ui/790-allow-reverting-asset-change
Oct 2, 2026
Merged

ledsoft merged 27 commits into
kbss-cvut:developmentfrom
lukaskabc:lukaskabc/ui/790-allow-reverting-asset-change

Conversation

@lukaskabc

Copy link
Copy Markdown
Collaborator

Implements kbss-cvut/termit-ui#790

Frontend PR: kbss-cvut/termit-ui#876

Rollback restrictions:

  • Term creation/deletion cannot be rolled back
  • Rollbacks are possible only for update change records (modification to asset attributes)
  • Rollback is possible only when:
    • The original value was literal (number, string...)
    • The original value was a reference to an asset (Term, Vocabulary), and the asset still exists.
      For example, when the original value referenced term that was already deleted, the rollback wont be possible, because the reference would be invalid. Whether the referenced resource is (or was) an asset is being resolved using the metamodel and custom attributes (with Term range).
    • The original value was a resource (URI), and a custom attribute with Resource (IRI/URI/URL) range exists.
      This means the URI is a general resource, and its existence will not be validated.

About additional properties:

  • Additional properties added through termit are currently saved as strings, so their changes can be rolled back
  • If some additional property is added in other means (custom attribute is removed, via import...) and its value is saved as IRI, the change won't be possible to rollback, because there is no indication whether it stores a valid reference or not.

Applying rollback creates a new change record and does not change previous change records.

Changes

This PR adds:

  • New change type in the Termit ontology termit:reversible-change representing a reversible update of an entity.
  • Enhanced /history endpoints of Vocabulary and Term adding termit:reversible-change type to change records that can be rolled back by the current user.
  • Two new endpoints for rolling back an update change record (again one for Vocabulary, and one for Term).
  • ChangeRollbackService for performing rollbacks
  • RollbackValidator validates whether the rollback of the given update change record would be possible without breaking the rules above

@lukaskabc lukaskabc added the enhancement New feature or request label Sep 23, 2026
@lukaskabc
lukaskabc marked this pull request as draft September 23, 2026 13:30
@lukaskabc

Copy link
Copy Markdown
Collaborator Author

The PR is put as a draft until kbss-cvut/jopa#483 is resolved, causing the rollback of a MultilingualString property possibly discarding all translations except one.

@ledsoft

ledsoft commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

JOPA 2.12.4 with the corresponding fix has been released, so should be ready to update and then can be reviewed

@lukaskabc
lukaskabc marked this pull request as ready for review September 30, 2026 11:44
… types to primitives in MetamodelRollbackValidator and fix ChangeRollbackDao reporting entity existance from inferred statements
…ng custom attributes referencing terms and possibly vocabularies
…nge sub-class of UpdateChangeRecord. Introduce rollback endpoints.
…history is returned with reversible types and rollback endpoint resolves update change record and calls rollback
…points in TermController and VocabularyController
…uring history is returned with reversible types and rollback endpoint resolves update change record and calls rollback
…ndCustomAttribute and ChangeRecordDao#find
…tilingual string does not discard other transaltions
@lukaskabc
lukaskabc force-pushed the lukaskabc/ui/790-allow-reverting-asset-change branch 2 times, most recently from c73a133 to ff9acd3 Compare September 30, 2026 11:52
…ected and fix rollbackOfMultilingualStringPreservesOtherTranslations test asserting equality of different object types
@lukaskabc
lukaskabc force-pushed the lukaskabc/ui/790-allow-reverting-asset-change branch from ff9acd3 to def14fb Compare September 30, 2026 11:53
@lukaskabc
lukaskabc requested a review from ledsoft September 30, 2026 11:57

@ledsoft ledsoft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels overengineered, I was expecting something simple using a SPARQL Update with some infrastructure around. But it is true that that would not produce the record of reverting the change.
Anyway, couple of change requests for simplification/refactoring, will test afterwards.

@lukaskabc

Copy link
Copy Markdown
Collaborator Author

Feels overengineered, I was expecting something simple using a SPARQL Update with some infrastructure around. But it is true that that would not produce the record of reverting the change.

I would also need to explicitly handle possible related changes that are not part of the change record (e.g. Term being root term in a vocabulary). And that, on the other side, sounds more like an ad-hoc solution.
Whereas now the rollback is an entity operation, and basic data integrity should be handled by JOPA/the model and repository services. Plus the automatic change record creation as you mentioned.

@lukaskabc
lukaskabc force-pushed the lukaskabc/ui/790-allow-reverting-asset-change branch from 19104f0 to 7a95974 Compare October 1, 2026 09:40
@lukaskabc
lukaskabc requested a review from ledsoft October 1, 2026 10:36
…replace it with direct references to the Vocabulary#s_c_reversible_change

@ledsoft ledsoft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ledsoft ledsoft linked an issue Oct 2, 2026 that may be closed by this pull request
@ledsoft
ledsoft merged commit 971cbb6 into kbss-cvut:development Oct 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow reverting asset change

2 participants